var vm = new Vue({
    el: '#app',
    data: {
        host: HOST,
        username: sessionStorage.username || localStorage.username,
        user_id: sessionStorage.user_id || localStorage.user_id,
        token: sessionStorage.token || localStorage.token,
        detail: '',
        title: '',
        tag: '',
        question_id: ''
    },
    methods:{
        on_submit: function () {
            this.detail = CKEDITOR.instances.editor_text.getData();
            if (this.username) {
                axios.post(this.host + 'question/submit/',
                    {
                        title: this.title,
                        tag: this.tag,
                        author: this.user_id,
                        detail: this.detail
                    },
                    {
                        responseType: 'json',
                    })
                    .then(response => {
                            this.questions_id = response.data.id
                            location.href = 'qa-detail.html?id=' + this.questions_id
                        }
                    )
            } else {
                location.href = 'person-loginsign.html?next=qa-submit.html'
            }
        }
    }
})
